package com.hightrast.service.api.baseEntity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.time.LocalDateTime;

public class BaseEntity<T extends Model<?>> extends Model<T> implements Serializable {
    @ApiModelProperty("主键id")
    @TableId(value = "id",type = IdType.ASSIGN_ID)
    private Long id;
    @ApiModelProperty("创建人id")
    @TableField("create_id")
    private Long createId;
    @JsonFormat(
        pattern = "yyyy-MM-dd HH:mm:ss"
    )
    @ApiModelProperty("创建时间")
    @TableField("create_time")
    private LocalDateTime createTime;
    @ApiModelProperty("修改人id")
    @TableField("modify_id")
    private Long modifyId;
    @JsonFormat(
        pattern = "yyyy-MM-dd HH:mm:ss"
    )
    @ApiModelProperty("最近一次修改时间")
    @TableField("modify_time")
    private LocalDateTime modifyTime;
    @TableLogic(
        value = "0",
        delval = "1"
    )
    @ApiModelProperty("删除标识，0-正常，1-删除")
    @TableField("is_deleted")
    private Integer isDeleted;

    public BaseEntity() {
    }

    public Long getId() {
        return this.id;
    }

    public Long getCreateId() {
        return this.createId;
    }

    public LocalDateTime getCreateTime() {
        return this.createTime;
    }

    public Long getModifyId() {
        return this.modifyId;
    }

    public LocalDateTime getModifyTime() {
        return this.modifyTime;
    }

    public Integer getIsDeleted() {
        return this.isDeleted;
    }

    public BaseEntity<T> setId(final Long id) {
        this.id = id;
        return this;
    }

    public BaseEntity<T> setCreateId(final Long createId) {
        this.createId = createId;
        return this;
    }

    public BaseEntity<T> setCreateTime(final LocalDateTime createTime) {
        this.createTime = createTime;
        return this;
    }

    public BaseEntity<T> setModifyId(final Long modifyId) {
        this.modifyId = modifyId;
        return this;
    }

    public BaseEntity<T> setModifyTime(final LocalDateTime modifyTime) {
        this.modifyTime = modifyTime;
        return this;
    }

    public BaseEntity<T> setIsDeleted(final Integer isDeleted) {
        this.isDeleted = isDeleted;
        return this;
    }

    public String toString() {
        return "BaseEntity(id=" + this.getId() + ", createId=" + this.getCreateId() + ", createTime=" + this.getCreateTime() + ", modifyId=" + this.getModifyId() + ", modifyTime=" + this.getModifyTime() + ", isDeleted=" + this.getIsDeleted() + ")";
    }

    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof BaseEntity)) {
            return false;
        } else {
            BaseEntity<?> other = (BaseEntity)o;
            if (!other.canEqual(this)) {
                return false;
            } else if (!super.equals(o)) {
                return false;
            } else {
                Object this$id = this.getId();
                Object other$id = other.getId();
                if (this$id == null) {
                    if (other$id != null) {
                        return false;
                    }
                } else if (!this$id.equals(other$id)) {
                    return false;
                }

                Object this$createId = this.getCreateId();
                Object other$createId = other.getCreateId();
                if (this$createId == null) {
                    if (other$createId != null) {
                        return false;
                    }
                } else if (!this$createId.equals(other$createId)) {
                    return false;
                }

                label71: {
                    Object this$createTime = this.getCreateTime();
                    Object other$createTime = other.getCreateTime();
                    if (this$createTime == null) {
                        if (other$createTime == null) {
                            break label71;
                        }
                    } else if (this$createTime.equals(other$createTime)) {
                        break label71;
                    }

                    return false;
                }

                label64: {
                    Object this$modifyId = this.getModifyId();
                    Object other$modifyId = other.getModifyId();
                    if (this$modifyId == null) {
                        if (other$modifyId == null) {
                            break label64;
                        }
                    } else if (this$modifyId.equals(other$modifyId)) {
                        break label64;
                    }

                    return false;
                }

                Object this$modifyTime = this.getModifyTime();
                Object other$modifyTime = other.getModifyTime();
                if (this$modifyTime == null) {
                    if (other$modifyTime != null) {
                        return false;
                    }
                } else if (!this$modifyTime.equals(other$modifyTime)) {
                    return false;
                }

                Object this$isDeleted = this.getIsDeleted();
                Object other$isDeleted = other.getIsDeleted();
                if (this$isDeleted == null) {
                    if (other$isDeleted != null) {
                        return false;
                    }
                } else if (!this$isDeleted.equals(other$isDeleted)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(final Object other) {
        return other instanceof BaseEntity;
    }

    public int hashCode() {
        int result = super.hashCode();
        Object $id = this.getId();
        result = result * 59 + ($id == null ? 43 : $id.hashCode());
        Object $createId = this.getCreateId();
        result = result * 59 + ($createId == null ? 43 : $createId.hashCode());
        Object $createTime = this.getCreateTime();
        result = result * 59 + ($createTime == null ? 43 : $createTime.hashCode());
        Object $modifyId = this.getModifyId();
        result = result * 59 + ($modifyId == null ? 43 : $modifyId.hashCode());
        Object $modifyTime = this.getModifyTime();
        result = result * 59 + ($modifyTime == null ? 43 : $modifyTime.hashCode());
        Object $isDeleted = this.getIsDeleted();
        result = result * 59 + ($isDeleted == null ? 43 : $isDeleted.hashCode());
        return result;
    }
}